package com.erp.servlet;

import com.erp.bean.Entrepot;
import com.erp.service.EntrepotService;
import com.erp.service.impl.EntrepotServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lyb
 * 创建添加仓库控制器
 */
@WebServlet("/addentrepot.action")
public class AddEntrepotServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取页面传递仓库名称
        String entname=req.getParameter("deptname");
        String loc=req.getParameter("loc");
        Entrepot entrepot=new Entrepot(entname,loc);

        EntrepotService entrepotService=new EntrepotServiceImpl();
        entrepotService.add(entrepot);
        //重定向到全部库存控制器
        resp.sendRedirect("entrepotlist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
